/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.storage.api;

import com.jeesite.modules.storage.service.BannerService;
import com.jeesite.modules.storage.service.PlateService;
import com.jeesite.modules.storage.common.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * APP Controller
 */
@RestController(value = "apiapp")
@RequestMapping(value = "/api/app")
class AppController extends APIController {

    @Autowired
    private BannerService bannerService;

    @Autowired
    private PlateService plateService;

    /**
     * 获取首页推荐
     * @param memberId 会员Id
     * @return 首页推荐
     */
    @RequestMapping(method = RequestMethod.GET,value = "recommend")
    @ResponseBody
    public ServerResponse<Map> recommend(@RequestParam(value="memberId") String memberId){
        Map map = new HashMap();
        map.put("banners",bannerService.getRecommends());
        map.put("limited",plateService.getLimitedRecommend(memberId));
        map.put("brandSelection",plateService.getBrandSelectionRecommend(memberId));
        map.put("specialField",plateService.getSpecialFieldRecommend(memberId));
        map.put("hot",plateService.getHotActivityRecommend(memberId));
        map.put("sale",plateService.getSaleActivityRecommend(memberId));
        return ServerResponse.createBySuccess(200,map);
    }
}